package util;

import redis.clients.jedis.*;

/**
 * USER: lintc 【lintiancong@zhuojianchina.com】
 * DATE: 2017-08-10 09:41
 */
public class RedisClient {
    private Jedis jedis; // 非切片额客户端链接
    private JedisPool jedisPool; // 非切片连接池
    private ShardedJedis shardedJedis; // 切片额客户端连接
    private ShardedJedisPool shardedJedisPool; // 切片连接池

    public RedisClient() {
        initialPool();
    }

    /**
     * 初始化非切片池
     */
    private void initialPool() {
        // 池基本配置
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(20);
        config.setMaxIdle(5);
        config.setMaxWaitMillis(10 * 1000);
        config.setTestOnBorrow(false);

        jedisPool = new JedisPool(config, "47.94.146.249", 6379);
    }

    public Jedis getRedis() {
        return jedisPool.getResource();
    }
}
